//
//  main.m
//  TemplateUpgradeHelper
//
//  Created by Vescky on 14/11/19.
//  Copyright (c) 2014年 Vescky. All rights reserved.
//

#import <Foundation/Foundation.h>
//#import "cmdUtilities.h"

void printfUsage();

int main(int argc, const char * argv[])
{

    @autoreleasepool { 
        if (argc < 2) {
            printf("\n too less args.\n");
            printfUsage();
            return -1;
        }
        NSString *strOp = [NSString stringWithUTF8String:argv[0]];
        NSString *platform = [NSString stringWithUTF8String:argv[1]];
        NSString *filePath = [NSString stringWithUTF8String:argv[2]];
        if (![strOp hasPrefix:@"--"]) {
            printf("\n pls input operator.\n");
            printfUsage();
            return -1;
        }
        if (!platform || platform.length < 1) {
            printf("\n pls input platform(ios/android).\n");
            printfUsage();
            return -1;
        }
        platform = [platform lowercaseString];
        if (![platform isEqualToString:@"ios"] || ![platform isEqualToString:@"android"]) {
            printf("\n pls input valid platform(ios/android).\n");
            printfUsage();
            return -1;
        }
        NSFileManager *fm = [NSFileManager defaultManager];
        if (![fm fileExistsAtPath:filePath]) {
            printf("\n file not exists!\n");
            printfUsage();
            return -1;
        }
        
        if ([strOp isEqualToString:@"--wip"]) {
            
        }
        else if ([strOp isEqualToString:@"--sq"]) {
            
        }
        else if ([strOp isEqualToString:@"--tm"]) {
            
        }
        else if ([strOp isEqualToString:@"--o2o"]) {
            
        }
        else {
            printf("\n invalid operator!\n");
            printfUsage();
            return -1;
        }
    }
    return 0;
}

void printfUsage() {
    printf("\n TemplateUpgradeHelper version:%s\nUsage: ./TemplateUpgradeHelper --[wip/sq/tm/o2o] [ios/android] [FilePath]\ne.g:./TemplateUpgradeHelper --wip ios AppsTemplate/Classes/Tab/Lynx/Layout1/Class/LynxProductList/Order/Controller/MicroMallLayout1OrderDetailViewController.m\n",[CURRENT_VERSION UTF8String]);
}

